import Request from '@/services';

interface rPromise {
  data: any;
  message: number;
  code: number;
  [key: string]: any;
}

/* 建物资讯设定 */
// 全部厂别
export const facListAll = async (params: any = {}): Promise<rPromise> =>
  await Request.post('/device/ice_maker_site_info/listAll', { data: params });
// 表格数据
export const tableListAll = (params: any = {}) =>
  Request.post('/device/ice_maker_building_info/listAll', { data: params });
// 修改 表格中的数据
export const tableUpdate = (params: any = {}) =>
  Request.post('/device/ice_maker_building_info/update', { data: params });
// 单个添加
export const tableAdd = async (params: any = {}) =>
  await Request.post('/device/ice_maker_building_info/add', { data: params });
// 单个删除
export const tableDel = async (params: any = {}) =>
  await Request.post('/device/ice_maker_building_info/del', { data: params });

/* 建物区域资讯设定 */
export const listAllByBuildingID = async (params: any = {}) =>
  await Request.post('/device/ice_maker_area_info/listAllByBuildingID', {
    data: params,
  });
// 更新数据
export const areaUpdate = async (params: any = {}) =>
  await Request.post('/device/ice_maker_area_info/update', { data: params });
// 单个添加
export const areaAdd = async (params: any = {}) =>
  await Request.post('/device/ice_maker_area_info/add', { data: params });
// 单个删除
export const areaDel = async (params: any = {}) =>
  await Request.post('/device/ice_maker_area_info/del', { data: params });

/* 感测器资讯设定 */
// 查询全部 感测器类型
export const deviceTypeList = async (params: any = {}) =>
  await Request.post('/device/ice_maker_device_type/listAll', { data: params });
// 根据选择的 site 查询
export const listAllBySiteID = async (params: any = {}) =>
  await Request.post('/device/ice_maker_building_info/listAllBySiteID', {
    data: params,
  });
// 根据感测器类型 查询
type GetModelList = { dType: string };
export const getModelList = async (params: GetModelList) =>
  await Request.post('/device/ice_maker_model_type/getModelList', {
    data: params,
  });
// 根据全部选择 查询
export const listDeviceListByCondition = async (params: any = {}) =>
  await Request.post(
    '/device/ice_maker_device_info/listDeviceListByCondition',
    { data: params },
  );
// 编辑 单个更新
export const deviceUpdate = async (params: any = {}) =>
  await Request.post('/device/ice_maker_device_info/update', { data: params });
// 单个添加
export const deviceAdd = async (params: any = {}) =>
  await Request.post('/device/ice_maker_device_info/add', { data: params });
// 单个删除
export const deviceDel = async (params: any = {}) =>
  await Request.post('/device/ice_maker_device_info/del', { data: params });

/* 上下限 */
// 默认查询
export const getIceMakerCemsSensorlimitsByIDAndItemID = async (params: any) =>
  await Request.post(
    '/device/ice_maker_cems_sensorlimits/getIceMakerCemsSensorlimitsByIDAndItemID',
    { data: params },
  );
// 单个添加
export const upperLowerAdd = async (params: any) =>
  await Request.post('/device/ice_maker_cems_sensorlimits/add', {
    data: params,
  });
// 单个编辑
export const upperLowerUpdate = async (params: any) =>
  await Request.post('/device/ice_maker_cems_sensorlimits/update', {
    data: params,
  });
// 单个删除
export const upperLowerDel = async (params: any) =>
  await Request.post('/device/ice_maker_cems_sensorlimits/del', {
    data: params,
  });

/* 智能调控  */
// 默认查询
export const listAllByDeviceTypeAndID = async (params: any = {}) =>
  await Request.post('/device/ice_maker_sensor_item/listAllByDeviceTypeAndID', {
    data: params,
  });
/*
  可控制存在时 使用编辑
  不存在时 使用添加
*/
// 单个更新
export const tagMapUpdate = async (params: any) =>
  await Request.post('/device/ice_maker_tag_mapping/update', { data: params });
// 单个添加
export const tagMapAdd = async (params: any) =>
  await Request.post('/device/ice_maker_tag_mapping/add', { data: params });
// 单个删除
export const tagMapDel = async (params: any) =>
  await Request.post('/device/ice_maker_sensor_item/del', { data: params });
// 批量上传
export const tagMapImport = async (params: any) =>
  // await Request('/device/ice_maker_tag_mapping/import', {
  //   method: 'POST',
  //   requestType: 'form',
  //   data: params
  // })
  await Request.post('/device/ice_maker_tag_mapping/import', {
    data: params,
    requestType: 'form',
  });

/* 感測器類別設定 */
/* 查询全部 */
// deviceTypeList
// 单个更新
export const sensorUpdate = async (params: any) =>
  await Request.post('/device/ice_maker_device_type/update', { data: params });
// 单个添加
export const sensorAdd = async (params: any) =>
  await Request.post('/device/ice_maker_device_type/add', { data: params });
// 查询 全部分类
export const getCodeDescByType = async (params: any) =>
  await Request.post('/device/ice_maker_code_desc/getCodeDescByType', {
    data: params,
  });

/* 感测项目设定 */
// 查询全部
export const sensorSetListAll = async (params: any) =>
  await Request.post('/device/ice_maker_sensor_item/listAllByDeviceTypeID', {
    data: params,
  });
// 单个 添加
export const sensorSetAdd = async (params: any) =>
  await Request.post('/device/ice_maker_sensor_item/add', { data: params });
// 单个 更新
export const sensorSetUpdate = async (params: any) =>
  await Request.post('/device/ice_maker_sensor_item/update', { data: params });

/* 系統資訊設定 */
// 查询全部
/* buildingid 系统资讯查询 */
export const getSystemInfoList = async (params: any) =>
  await Request.post('/device/ice_maker_system/getSystemInfoList', {
    data: params,
  });
/* sId 设备资讯查询 */
export const getEquipmentList = async (params: any) =>
  await Request.post('/device/ice_maker_equipment/getEquipmentList', {
    data: params,
  });
